package com.xjm.entity.model;

import cn.hutool.json.JSON;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xjm.constant.Update;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * <p>
 *
 * </p>
 *
 * @author xjm
 * @since 2025-02-27
 */
@Data
@TableName("products")
public class ProductsModel implements Serializable {
    /**
     * 自增id
     */
    @NotNull(message = "id不能为空", groups = {Update.class})
    private Integer id;

    @NotBlank(message = "商品名称不能为空")
    private String name;
    @NotBlank(message = "商品描述不能为空")
    private String description;

    @DecimalMin(message = "商品价格不能为空", value = "1")
    private BigDecimal price;

    private Integer stock;

    /**
     * 商品主图
     */
    @NotBlank(message = "商品图片不能为空")
    private String image;

    private String scenario;

    private Object other;

    /**
     * 1:在售 0:下架
     */
    private Integer status;

    /**
     * 商品分类id
     */
    private Integer classifyId;

    /**
     * 销量
     */
    private Integer sales;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.UPDATE)
    private Date updatedTime;
}
